<?php
/**
 * Created by PhpStorm.
 * User: xaq
 * Date: 2017/6/5
 * Time: 9:28
 */

namespace app\api\model;


class Order extends BaseModel
{
    protected $hidden = ['usr_id','delete_time','update_time'];

    public function getSnapItemsAttr($value){
        if(empty($value)){
            return null;
        }
        return json_decode($value);
    }
    //读取器
    public function getSnapAddressAttr($value) {
        if(empty($value)){
            return null;
        }
        return json_decode($value);
    }

    public static function getSummaryByUser($uid, $page, $size) {
        $pagingData = self::where('user_id','=',$uid)
            ->order('create_time','desc')
            ->paginate($size,true,['page'=>$page]);
        return $pagingData;
    }
}